package com.anjubao.parking.municipal.user.feign;

import com.anjubao.parking.municipal.common.dto.ApiResult;
import com.anjubao.parking.municipal.user.dto.*;
import com.anjubao.parking.municipal.user.form.UserBalancePayForm;
import com.anjubao.parking.municipal.user.form.UserInfoUpdateForm;
import com.anjubao.parking.municipal.user.form.VehicleBindForm;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 用户中心feign接口
 *
 * @author zhuchunfeng
 * @date 2019/6/20 17:31
 */

public interface UserFeignService {

    @ApiOperation("2.1.1 获取验证码")
    @GetMapping("/parking-app-user/captcha/{phone}")
    ApiResult<CaptchaDto> getCaptcha(@ApiParam(value = "手机号") @PathVariable("phone") String phone);

    /**
     * 验证码有误抛出异常
     */
    @ApiOperation("2.1.2 校验验证码接口")
    @PostMapping("/parking-app-user/captcha/validate")
    ApiResult<UserInfoDto> validateCaptcha(@ApiParam(value = "手机号", required = true) @RequestParam(value = "phone", required = true) String phone,
                                           @ApiParam(value = "验证码", required = true) @RequestParam(value = "captcha", required = true) String captcha);

    /**
     * 若用户不存在返回null
     */
    @ApiOperation("2.1.3 获取用户信息")
    @GetMapping("/parking-app-user/user")
    ApiResult<UserDetailDto> getUserInfo(@ApiParam(value = "16位用户编号", required = true) @RequestParam(value = "userCode", required = true) String userCode);

    /**
     * 通过userCode更新指定用户信息
     * 若用户不存在抛出异常
     */
    @ApiOperation("2.1.3_1 根据userCode修改用户信息")
    @PostMapping("/parking-app-user/user/user-code")
    ApiResult<UserDetailDto> updateUserInfoByUserCode(@RequestBody UserInfoUpdateForm userInfoUpdateForm);

    /**
     * 通过unionID更新指定用户信息
     * 若用户不存在抛出异常
     */
    @ApiOperation("2.1.3_2 通过unionID修改用户信息")
    @PostMapping("/parking-app-user/user/union-id")
    ApiResult<UserDetailDto> updateUserInfoByUnionId(@RequestBody UserInfoUpdateForm userInfoUpdateForm);


    /**
     * 用户余额充值,余额不足抛出异常
     */
    @PostMapping("/parking-app-user/users/balances")
    @ApiOperation("2.1.4 用户余额充值消费接口")
    ApiResult<UserBalanceDto> balancePay(@RequestBody UserBalancePayForm userBalancePayForm);

    /**
     * 用户不存在返回null
     */
    @GetMapping("/parking-app-user/users/vehicles")
    @ApiOperation("2.1.6 用户已绑定车牌获取接口")
    ApiResult<UserInfoDto> getUserVehicles(@ApiParam(value = "16位用户编号", required = true) @RequestParam(value = "userCode", required = true) String userCode);

    @GetMapping("/parking-app-user/users/balances/records")
    @ApiOperation("2.1.7 用户充值消费账单查询接口")
    ApiResult<List<UserBalanceRecordDto>> getUserBalanceRecords(@ApiParam(value = "16位用户编号", required = true) @RequestParam(value = "userCode", required = true) String userCode,
                                                                            @ApiParam(value = "1充值 2消费 不传查全部",required = false) @RequestParam(value = "type",required = false) Integer type,
                                                                            @ApiParam(value = "当前页码，默认为第一页") @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                                            @ApiParam(value = "分页大小，默认分页大小为10") @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize);

    /**
     * 通过车牌号查询用户信息,用户不存在返回null
     */
    @GetMapping("/parking-app-user/vehicle/user")
    @ApiOperation("2.1.8 通过车牌号获取用户")
    ApiResult<UserInfoDto> getUserByVehicle(@ApiParam(value = "车牌号", required = true) @RequestParam(value = "vehicle", required = true) String vehicle);

    @PostMapping("/parking-app-user/vehicle/bind")
    @ApiOperation("2.1.9 解绑/绑定 车牌号")
    ApiResult<UserInfoDto> bindVehicle(@RequestBody VehicleBindForm vehicleBind);
}
